package com.xbs.controller.enterprise;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xbs.controller.base.BaseServlet;
import com.xbs.entity.EpOrderAdminEntity;
import com.xbs.entity.EpOrderAdminQueryEntity;
import com.xbs.service.enterprise.EpOrderQueryAdminService;
import com.xbs.utils.PageUtilEntity;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.util.CycleDetectionStrategy;
@WebServlet("/backstage/enterpriseOrder/querymul1")
public class EpOrderQueryAdminController extends BaseServlet{
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String status=req.getParameter("status");
		String startTime=req.getParameter("startTime");
		String endTime=req.getParameter("endTime");
		Integer orderType=Integer.parseInt(req.getParameter("orderType"));
		String keyWord=req.getParameter("keyWord");
		Integer curr=Integer.parseInt(req.getParameter("curr"));
		Integer size=Integer.parseInt(req.getParameter("size"));
		EpOrderAdminQueryEntity q=new EpOrderAdminQueryEntity();
		q.setEndTime(endTime);
		q.setKeyWord(keyWord);
		q.setOrderType(orderType);
		q.setStartTime(startTime);
		q.setStatus(status);
		EpOrderQueryAdminService service=new EpOrderQueryAdminService();
		PageUtilEntity<EpOrderAdminEntity> page=service.getOrdersByMul(q,curr,size);
		
		JsonConfig jsonConfig = new JsonConfig();   
		jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);   
		jsonConfig.registerJsonBeanProcessor(java.sql.Date.class, new DateJsonValueProcessor());  
		jsonConfig.setExcludes(new String[]{"handler","hibernateLazyInitializer"});    
		/*JSONArray.fromObject(list,jsonConfig);  */
		//JSONArray jsonArray = JSONArray.fromObject(page.getIst(),jsonConfig);
		JSONObject obj =JSONObject.fromObject(page,jsonConfig); 
		resp.getWriter().print(obj.toString());
		
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
}
